package com.hjxy.service.impl;

import com.hjxy.dao.ClassroomDao;
import com.hjxy.pojo.Classroom;
import com.hjxy.service.ClassroomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: fcz
 * @createDate: 2020/9/29
 * @version: 1.0
 */@Service
public class ClassroomServiceImpl implements ClassroomService {
    @Autowired
    private ClassroomDao classroomDao;

    @Autowired //自动装备
    public ClassroomServiceImpl(ClassroomDao classroomDao) {
        this.classroomDao = classroomDao;
    }

    @Override
    public List<Classroom> getAll() {
        return classroomDao.queryAll();
    }

    @Override
    public int addOne(Classroom classroom) {
        return classroomDao.addOne(classroom);
    }

    @Override
    public int deleteById(Integer classroomId) {
        int result = classroomDao.deleteById(classroomId);

        return result;
    }

    @Override
    public int updateByClassroom(Classroom classroom) {
        return classroomDao.updateByClassroom(classroom);
    }

//    @Override
//    public boolean removeOne(Classroom classroom) {
//        int result = classroomDao.deleteByUser(classroom);
//        return result > 0;
//    }

//   @Override
//    public Classroom getOneByClassroomId(Integer classroomId) {
//        Classroom classroom = classroomDao.queryById(classroomId);
//        System.out.println(classroom);
//        return classroom;
//    }
//
//    @Override
//    public Classroom getOneByClassroomname(String classroomname) {
//        return classroomDao.queryByUsername(classroomname);
//    }
//
//    @Override
//    public PageInfo<Classroom> getClassroomsByPage(Integer currentPage, Integer pageSize) {
//        //准备拦截mybatis后续的查询
//        PageHelper.startPage(currentPage, pageSize);
//        List<Classroom> classroomList = classroomDao.queryAll();
//        System.out.println(classroomList.size());
//        //pagehelper内部计算总共有多少页
//        PageInfo<Classroom> pageInfo = new PageInfo<>(classroomList);
//        return pageInfo;
//    }
//
//    @Override
//    public int addOne(Classroom classroom) {
//        return classroomDao.addOne(classroom);
//        // int result = classroomDao.insertByUser(classroom);
//        //判断添加的用户的角色信息是否为空
//        //遍历用户的角色，以循环执行user_role表的插入动作
////            for(Role role:classroom.getRoles()){
////                //构造UserRole对象
////                Classroom classroom = new Classroom();
////                classroom.setRoleId(role.getRoleId());
////                classroom.setClassroomId(classroom.getClassroomId());
////                //让userRoleDao执行插入UserRole
////                classroomDao.insert(classroomRole);
////            }
//
//    }




//
//    @Override
//    @Transactional //注明当前的方法事务性执行
//    public boolean modifyOne(Classroom classroom) {
//        int result = classroomDao.updateByUser(classroom);
//        return result > 0;
//    }
//
//    @Override
//    //逻辑删除一批用户
//    public boolean removeSome(Set<Integer> classroomIds) {
//        int result = classroomDao.deleteByIds(classroomIds);
//        return result > 0;
//    }
//
//    @Override
//    public Set<Classroom> getClassroomThatAddressLike(String address) {
////        这里address就是数据库user表的列名
//        String column = "address";
//        return classroomDao.queryByColumn(column, address);
//    }
//
//    @Override
//    public Set<Classroom> getClassroomWithMultiCondition(String classroomId, int state) {
//        return classroomDao.queryByMultiConditions(classroomId);
//    }
}
